<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'UpdatePwd.jsp' starting page</title>
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="layui-v1.0.9_rls/layui/css/layui.css"
	type="text/css"></link>
<script type="text/javascript"
	src="layui-v1.0.9_rls/layui/lay/dest/layui.all.js"></script>

<style>
.input {
	width: 400px;
}
</style>
</head>

<body>
	<div class="layui-tab">
		<ul class="layui-tab-title">
			<li class="layui-this">网站设置</li>
			<li>修改密码</li>

		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				1. 高度默认自适应，也可以随意固宽。 <br>2. Tab进行了响应式处理，所以无需担心数量多少。
			</div>
			<div class="layui-tab-item input">
				<form class="layui-form" action="backstage/upPassword" method="post">
					<input type="hidden" name="phone" value="${userInfo.phone }"
						id="phone" />
					<div class="layui-form-item">
						<label class="layui-form-label">原始密码</label>
						<div class="layui-input-inline">
							<input type="password" name="password" required
								lay-verify="required" placeholder="请输入密码" autocomplete="off"
								class="layui-input" id="password">
						</div>
						<div class="layui-form-mid layui-word-aux">一定要填写哦</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">新密码</label>
						<div class="layui-input-inline">
							<input type="password" name="password1" required
								lay-verify="required" placeholder="请输入密码" autocomplete="off"
								class="layui-input">
						</div>
						<div class="layui-form-mid layui-word-aux">一定要填写哦</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">验证码</label>
						<div class="layui-input-block">
							<input type="text" name="title" placeholder="请输入标题"
								autocomplete="off" class="layui-input" id="a">
							<div id="checkNum">获取验证码</div>
						</div>

					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" id="submit"  lay-submit lay-filter="formDemo">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>

		</div>
	</div>


	<script>
		$(function() {

			$("#password").on(
					"blur",
					function() {
						var Opwd = $("#password").val();
						var Ophone = $("#phone").val();

						$.ajax({

							url : "backstage/search?phone=" + Ophone
									+ "&password=" + Opwd,
							success : function(json) {
								var msg = JSON.parse(json);

								if (msg == "") {
									alert("与原始密码不匹配，请重新输入！");
								}
							}
						})
					})

		});

		$("#checkNum").on("click", function() {
			$.ajax({

				url : "backstage/getRandom",
				success : function(data) {
					var a = JSON.parse(data);

					if (a != null) {
						alert("请接收验证码");
					}
				}
			});

		});
		
		
			$("#submit").on("click",function(){
				var ocode=$("#a").val();
				var cheakNum=$("#checkNum").val();
				if(cheakNum==ocode){
					flag=true;
				}else{
					alert("验证码错误,请重新获取验证码!");
				}
				return flag;


		});
	</script>


</body>
</html>
